/*
 * 百度在线网络技术（北京）有限公司拥有本软件版权2021并保留所有权利。
 * Copyright 2021, Baidu.com,Inc 2:Baidu Online Network Technology (Beijing) Co.,Ltd,
 * All rights reserved.
 */

package com.azdebugit.moshi.test.learn.otherfactory.test.method1._3创建一个工厂_生成基于给定信息的实体类的对象;

import com.azdebugit.moshi.test.learn.otherfactory.test.method1._1创建一个接口.Shape;
import com.azdebugit.moshi.test.learn.otherfactory.test.method1._2创建实现接口的实体类.Circle;
import com.azdebugit.moshi.test.learn.otherfactory.test.method1._2创建实现接口的实体类.Rectangle;
import com.azdebugit.moshi.test.learn.otherfactory.test.method1._2创建实现接口的实体类.Square;

public class ShapeFactory {
    
   //使用 getShape 方法获取形状类型的对象
   public Shape getShape(String shapeType){
      if(shapeType == null){
         return null;
      }        
      if(shapeType.equalsIgnoreCase("CIRCLE")){
         return new Circle();
      } else if(shapeType.equalsIgnoreCase("RECTANGLE")){
         return new Rectangle();
      } else if(shapeType.equalsIgnoreCase("SQUARE")){
         return new Square();
      }
      return null;
   }
}